package com.kingstar.ceres.data.remote;

import org.apache.commons.lang3.StringUtils;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

public interface ConnectionWrapper {

    boolean connection();
    void close();

    /**
     * @param srcPath 资源文件全路径
     * @param dstPath 下载目标地址全路径
     * @return
     */
    boolean upload(String srcPath,String dstPath);

    /**
     * @param srcPath 资源文件全路径
     * @param dstPath 下载目标地址全路径
     * @return
     */
    boolean download(String srcPath,String dstPath);

    String buildRemotePath(String dir,String filename);

    default void setIfNotEmpty(String value, Consumer<String> consumer){
        if(StringUtils.isNotBlank(value)){
            consumer.accept(value);
        }
    }
    default void setIfNotEmpty(String key, String value, BiConsumer<String,String> consumer){
        if(StringUtils.isNotBlank(value)){
            consumer.accept(key,value);
        }
    }
}
